package cn.itlaobing.springbootdemo.entity;


import org.springframework.data.jpa.domain.AbstractPersistable;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name="classes")
public class Classes extends AbstractPersistable<Long> {

    @Column(length = 30,nullable = false)
    private String name;

    //FetchType.EAGER 表示查询classes的时候，一起将班级中的学生查询出来
    //默认是 FetchType.LAZY，即不加载
    @OneToMany(mappedBy = "classes",fetch = FetchType.EAGER)
    private List<Student> students;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Student> getStudents() {
        return students;
    }

    public void setStudents(List<Student> students) {
        this.students = students;
    }
}
